package game.modifier;

import game.util.TraitUtil;
import game.util.Util;
import game.util.TraitUtil.Agreeableness;
import game.util.TraitUtil.Conscientiousness;
import game.util.TraitUtil.Extraversion;
import game.util.TraitUtil.Neuroticism;
import game.util.TraitUtil.Openness;
import game.util.TraitUtil.Trait;

import java.util.Collection;
import java.util.Date;

public class PersonModifier {
	private Date expires;
	private int looksModify;
	private Collection<Trait> traits;

	public enum ModifyField {
		LOOKS, OPENNESS, CONSCIENTIOUSNESS, EXTRAVERSION, AGREEABLENESS, NEUROTICISM,
	}

	public void modifyField(ModifyField field, int value) {
		switch (field) {
		case LOOKS:
			this.looksModify += value;
			break;
		case OPENNESS:
			Openness openness = TraitUtil.getOpenness(traits);
			openness.setValue(openness.getValue() + value);
			break;
		case CONSCIENTIOUSNESS:
			Conscientiousness conscientiousness = TraitUtil
					.getConscientiousness(traits);
			conscientiousness.setValue(conscientiousness.getValue() + value);
			break;
		case EXTRAVERSION:
			Extraversion extraversion = TraitUtil.getExtraversion(traits);
			extraversion.setValue(extraversion.getValue() + value);
			break;
		case AGREEABLENESS:
			Agreeableness agreeableness = TraitUtil
					.getAgreeableness(traits);
			agreeableness.setValue(agreeableness.getValue() + value);
			break;
		case NEUROTICISM:
			Neuroticism neuroticism = TraitUtil.getNeuroticism(traits);
			neuroticism.setValue(neuroticism.getValue() + value);
			break;
		}
	}
	
	public int getLooksModify() {
		return looksModify;
	}

	public PersonModifier(int duration) {
		final TraitUtil traitGenerator = new TraitUtil();
		this.expires = Util.getFutureDate(duration);
		this.looksModify = 0;
		this.traits = traitGenerator.getEmptyTraits();
	}

	public PersonModifier() {
		final TraitUtil traitGenerator = new TraitUtil();
		this.expires = null;
		this.looksModify = 0;
		this.traits = traitGenerator.getEmptyTraits();
	}

	public boolean isExpired(Date date) {
		if (this.expires != null)
			return this.expires.compareTo(date) <= 0;
		return false;
	}
}
